/**
* Copyright @ 2023 iAuto (Shanghai) Co., Ltd.
* All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are NOT permitted except as agreed by
* iAuto (Shanghai) Co., Ltd.
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*/


import request from '@/utils/request';
import { Methods } from '@/types/soaSocType';

// 获取一型一档能力json(webide用)
// http://iauto-yapi.ci.iauto.com/project/49/interface/api/249
export function getSkillList(params: {
  modelCode: string;
  seriesCode: string;
  socVersion?: string;
}) {
  return request(`/api/ms-soa-skill/v1/admin/skill/all`, {
    method: Methods.GET,
    params: params,
  });
}

// 获取能力编辑竞合关系（webide）
// http://iauto-yapi.ci.iauto.com/project/49/interface/api/294
export function getEditerCompeteList(params: { modelCode: string; seriesCode: string }) {
  return request(`/api/ms-soa-skill/v1/admin/skill/editor/compete/list`, {
    method: Methods.GET,
    params: params,
  });
}

interface ISceneUploadParams {
  sceneUuid?: string;
  modelCode: string;
  seriesCode: string;
  brandCode: string;
  brandName: string;
  blocks: string;
  name: string;
  description?: string;
  version?: string;
  socVersion?: string;
  iconUrl?: string;
  backgroundUrl?: string;
}

interface ISenceUploadResponse {
  data: string;
  statusCode: string;
  statusMessage: string;
}

// 新建/更新场景
// http://iauto-yapi.ci.iauto.com/project/55/interface/api/753
export function sceneUpload(params: ISceneUploadParams) {
  return request<ISenceUploadResponse>(`/api/ms-soa-scene-builder/v1/scene/upload`, {
    method: Methods.POST,
    data: params,
  });
}

interface ISceneDetailParams {
  sceneUuid: string;
  modelCode: string;
  seriesCode: string;
}

interface ISenceDetailResponse {
  data: {
    sceneUuid: string;
    modelCode: string;
    modelName: string;
    seriesCode: string;
    seriesName: string;
    brandCode: string;
    brandName: string;
    blocks: string;
    name: string;
    description: string;
    version: string;
    iconUrl: string;
    backgroundUrl: string;
    categoryName: string;
    categoryUuid: string;
    sceneFileUuid: string;
    executedOnPhone: number;
    doubleCheckOnVehicle: number;
    officialScene: number;
    cycleExecution: number;
    deployStatus: number;
    
  };
  statusCode: string;
  statusMessage: string;
}

// 获取场景数据
// http://iauto-yapi.ci.iauto.com/project/55/interface/api/762
export function sceneDetail(params: ISceneDetailParams) {
  return request<ISenceDetailResponse>(`/api/ms-soa-scene-builder/v1/scene/detail`, {
    method: Methods.GET,
    params: params,
  });
}

// 上传文件
// https://yapi.ci.iauto.com/project/790/interface/api/20805

export function uploadFiles(params: ISceneDetailParams) {
  return request(`/api/ms-soa-filestorage/v2/files`, {
    method: Methods.POST,
    params: params,
  });
}

interface ISceneBlocksDetailParams {
  modelCode: string;
  seriesCode: string;
  socVersion: string;
  fileUuid: string;
}


interface ISceneBlocksDetailResponse {
  data: {
    blocks: string;
  };
  statusCode: string;
  statusMessage: string;
}

// http://iauto-yapi.ci.iauto.com/project/55/interface/api/10026
export function getBlocksDetail(params: ISceneBlocksDetailParams) {
  return request<ISceneBlocksDetailResponse>(`/api/ms-soa-scene-builder/v1/scene/blocksDetail`, {
    method: Methods.GET,
    params: params,
  });
}